<?php
/*
 * Created on 2010-12-29
 * by lixilei
 */

class UserBiz {
	
	/**
	 * 新用户注册
	 */
	public function register($email, $password){
		$userDB = spClass("UserModel", null, MODEL_PATH."UserModel.php");
		$result = $userDB->find(array("email"=>$email));
		if($result != FALSE){
			return FALSE;
		}
		$result = $userDB->create(array("email"=>$email, "password"=>$password));
		if($result != FALSE){
			$result = $userDB->find(array("email"=>$email, "password"=>$password));
			if($result != FALSE){
				return $result;
			}
			return FALSE;
		}
		return FALSE;
	}
	
	/**
	 * 用户登录
	 */
	public function login($email, $password){
		$userDB = spClass("UserModel", null, MODEL_PATH."UserModel.php");
		$result = $userDB->find(array("email"=>$email, "password"=>$password));
		if($result != FALSE){
			return $result;
		}
		return FALSE;
	}
	
	/**
	 * 更新用户信息
	 */
	public function freshUserInfo($user_id){
		$userDB = spClass("UserModel", null, MODEL_PATH."UserModel.php");
		$result = $userDB->find(array("user_id"=>$user_id));
		if($result != FALSE){
			return $result;
		}
		return FALSE;
	}
}
?>
